<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller{
	public function login(){
		$this->display();
	}
	public function  dologin(){
      $condition=array(
         'adminname'=>$_POST['adminname'],
         'password'=>md5(I('post.password'))
      	);
      $adminModel=M('admins');
      $admin=$adminModel->where($condition)->find();
      var_dump($admin);
      if ($admin) {
      	// 是合法用户,设置session值
      	session('adminname',$_POST['adminname']);
     	$this->redirect('Index/index');
      }
      else
      {
      	// 非法用户
      	$this->error('用户名与密码不匹配!!!');
      }
	}
	public function logout(){
      session('adminname',null);
      //exit;
      $this->redirect('login');
	}
}
?>